#include<iostream>
#include<stdio.h>
class Complex{
private:
  double real;
  double imag;
public:
  Complex();
  Complex(double real, double imag);
  //~Complex();
double getReal();
double  getImag();
void setReal(double re);
void setImag(double im);
Complex operator+(Complex c);
Complex operator+(double d);
Complex operator=(const Complex &c);

friend std::ostream& operator<<(std::ostream& out, Complex c);
};

//Complex::~Complex()
//{
//printf("\nObiectul (%f,%f) a fost distrus",(*this).real,(*this).imag);
//}
Complex:: Complex() {
(*this).real=0.0;
(*this).imag=0.0;
}
Complex:: Complex(double real, double imag){
     (*this).real=real;
      (*this).imag=imag;
}
Complex Complex::operator+(Complex z){
   double real;
   double imag;
    real=(*this).real+z.getReal();
    imag=(*this).imag+z.getImag();
    Complex s=Complex(real,imag);
    return s;
}
Complex Complex::operator+(double d)
{
double real,imag;
imag=(*this).imag;
real=(*this).real+d;
Complex s=Complex(real,imag);
return s;
}
Complex Complex::operator=(const Complex &c)
{
this->real = c.real;
this->imag = c.imag;
return *this;
}
double Complex::getReal(){
    double real;
    real=(*this).real;
    return real;
}
double Complex::getImag(){
     double imag;
     imag=(*this).imag;
     return imag;
}
void Complex::setReal(double real){
    (*this).real=real;
}
void Complex::setImag(double imag){
     (*this).real=real;
}
 std::ostream& operator<< (std::ostream& out,Complex c)
{
out<<"Real="<<c.real<<"   Imag="<<c.imag;
return out;
}
int main()
{
int n,i;
double real,imag,d,sreal=0.0,simag=0.0;
std::cout<<"\nnr de incrementat=";
std::cin>>d;
std::cout<<"introduceti n=";
std::cin>>n;
Complex c[n];
for(i=0;i<n;i++)
{
std::cout<<"\nc["<<i<<"].real=";
std::cin>>real;
std::cout<<"    c["<<i<<"].imag=";
std::cin>>imag;
c[i]=Complex(real,imag);
sreal+=real;
simag+=imag;
}
Complex s=Complex(sreal,simag);
std::cout<<"Suma nr complexe este: "<<s;
std::cout<<"\nSirul incrementat este";
for(i=0;i<n;i++)
{
c[i]=c[i]+d;
std::cout<<"\n"<<c[i];
}
return 0;

}

